package main

import (
	"fmt"
	"sync"
	"time"
)

var m = sync.Mutex{}
var n = 100000000
func main(){
	start := time.Now().Unix()
	testCall()
	start1 := time.Now().Unix()
	testDeferCall()
	start2 := time.Now().Unix()

	fmt.Printf("testCall time:%v\n",start1-start)
	fmt.Printf("testDeferCall time:%v\n",start2-start1)

}

func call(){
	m.Lock()
	m.Unlock()
}

func deferCall(){
	m.Lock()
	defer m.Unlock()
}


func testCall(){
	for i:=0 ;i<n;i++{
		call()
	}
}

func testDeferCall(){
	for i:=0 ;i<n;i++{
		deferCall()
	}
}